<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">

<h:head>

</h:head>

<h:body>
	<div>
		<h:form>
			<p:tabMenu activeIndex="0">
				<p:menuitem value="Overview" url="/ui/tabMenu.jsf"
					icon="ui-icon-star" />
				<p:menuitem value="Demos" url="/ui/tabMenuDemos.jsf"
					icon="ui-icon-search" />
				<p:menuitem value="Documentation" url="/ui/tabMenuDocumentation.jsf"
					icon="ui-icon-document" />
				<p:menuitem value="Support" url="/ui/tabMenuSupport.jsf"
					icon="ui-icon-wrench" />
				<p:menuitem value="Social" url="/ui/tabMenuSocial.jsf"
					icon="ui-icon-person" />
			</p:tabMenu>
		</h:form>
	</div>
	<div>
		<h:outputLink id="loginLink" value="javascript:void(0)"
			onclick="dlg.show()" title="login">
			<p:graphicImage value="/images/login.png" />
		</h:outputLink>

		<p:growl id="growl" showDetail="true" life="3000" />

		<p:dialog id="dialog" header="Login" widgetVar="dlg">
			<h:form>

				<h:panelGrid columns="2" cellpadding="5">
					<h:outputLabel for="username" value="Username:" />
					<p:inputText value="#{customer.iCustomerNr}" id="username"
						required="true" label="username" />

					<h:outputLabel for="password" value="Password:" />
					<h:inputSecret value="#{customer.sEnteredPassword}" id="password"
						required="true" label="password" />

					<f:facet name="footer">
						<p:commandButton id="loginButton" value="Login" update=":growl"
							actionListener="#{loginCtrl.checkPW}"
							oncomplete="handleLoginRequest(xhr, status, args)" />
					</f:facet>
				</h:panelGrid>

			</h:form>
		</p:dialog>

		<script type="text/javascript">
			function handleLoginRequest(xhr, status, args) {
				if (args.validationFailed || !args.loggedIn) {
					jQuery('#dialog').effect("shake", {
						times : 3
					}, 100);
				} else {
					dlg.hide();
					jQuery('#loginLink').fadeOut();
				}
			}
		</script>
	</div>
</h:body>
</html>
